# attacter setting
import pygame

class AlienLaser(pygame.sprite.Sprite):
    def __init__(self,pos,speed,screen_height):
        super().__init__()
        file_path = '../graphics/alienlaser.png'# the files are named by color
        self.image = pygame.image.load(file_path).convert_alpha()
        self.rect = self.image.get_rect(center = pos)
        self.speed = speed
        self.height_y_constraint = screen_height

    # kill the laser when outside the screen
    def destroy(self):
        if self.rect.y <= -50 or self.rect.y >= self.height_y_constraint +50:
            self.kill()
    
    def update(self):
        self.rect.y += self.speed
        self.destroy()